//
//  MyDiscountTableViewCell.m
//  Findif
//
//  Created by Mac on 2019/4/3.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "MyDiscountTableViewCell.h"

@interface MyDiscountTableViewCell ()

@property (nonatomic, weak)UIImageView * backImageView;
@property (nonatomic, weak)UIImageView * showImageView;
@property (nonatomic, strong)UILabel * ruleLabel;
@property (nonatomic, strong)UILabel * moneyLabel;
@property (nonatomic, strong)UILabel * symbolLabel;
@property (nonatomic, strong)UILabel * conditionLabel;
@property (nonatomic, strong)UILabel * nameLabel;
@property (nonatomic, strong)UILabel * shopLabel;
@property (nonatomic, strong)UILabel * timeLabel;
@property (nonatomic, weak)UILabel * ruleContentLabel;
@property (nonatomic, weak)UIButton * useButton;

@property (nonatomic, copy)NSString * type;
@property (nonatomic, copy)NSString * goodsType;

@end

#define eatColor ColorWithRGB(0xF0614C)
#define playColor ColorWithRGB(0xBC80FF)
#define sportsColor ColorWithRGB(0x65DEC6)
#define travleColor ColorWithRGB(0x7EB5FF)
#define allColor ColorWithRGB(0xFAC851)

@implementation MyDiscountTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.type = @"hidden";
        [self setupUI];
    }
    
    return self;
}


- (void)setCouponModel:(CouponModel *)couponModel{
    
    _couponModel = couponModel;
    
    int usable_goods_type = [couponModel.usable_goods_category_id intValue];
    if (usable_goods_type == 0) {
        
        self.nameLabel.textColor = allColor;
        self.conditionLabel.textColor = allColor;
        self.ruleLabel.textColor = allColor;
        self.timeLabel.textColor = allColor;
        //            self.symbolLabel.textColor = allColor;
        //            self.moneyLabel.textColor = allColor;
        self.shopLabel.textColor = allColor;
        [self.useButton setTitleColor:allColor forState:UIControlStateNormal];
        self.showImageView.image = [UIImage imageNamed:@"全场_收起"];
        self.backImageView.image = [UIImage imageNamed:@"全场普通"];
    }else if (usable_goods_type == 1137){
        
        self.nameLabel.textColor = eatColor;
        self.conditionLabel.textColor = eatColor;
        self.ruleLabel.textColor = eatColor;
        self.timeLabel.textColor = eatColor;
        //            self.symbolLabel.textColor = eatColor;
        //            self.moneyLabel.textColor = eatColor;
        self.shopLabel.textColor = eatColor;
        [self.useButton setTitleColor:eatColor forState:UIControlStateNormal];
        self.showImageView.image = [UIImage imageNamed:@"关闭-吃喝"];
        self.backImageView.image = [UIImage imageNamed:@"普通吃喝"];
    }else if (usable_goods_type == 1138){
        
        self.nameLabel.textColor = playColor;
        self.conditionLabel.textColor = playColor;
        self.ruleLabel.textColor = playColor;
        self.timeLabel.textColor = playColor;
        //            self.symbolLabel.textColor = playColor;
        //            self.moneyLabel.textColor = playColor;
        self.shopLabel.textColor = playColor;
        [self.useButton setTitleColor:playColor forState:UIControlStateNormal];
        self.showImageView.image = [UIImage imageNamed:@"全场_玩乐"];
        self.backImageView.image = [UIImage imageNamed:@"普通玩乐"];
    }else if (usable_goods_type == 1139){
        
        self.nameLabel.textColor = sportsColor;
        self.conditionLabel.textColor = sportsColor;
        self.ruleLabel.textColor = sportsColor;
        self.timeLabel.textColor = sportsColor;
        //            self.symbolLabel.textColor = sportsColor;
        //            self.moneyLabel.textColor = sportsColor;
        self.shopLabel.textColor = sportsColor;
        [self.useButton setTitleColor:sportsColor forState:UIControlStateNormal];
        self.showImageView.image = [UIImage imageNamed:@"全场_运动"];
        self.backImageView.image = [UIImage imageNamed:@"普通运动"];
    }else if (usable_goods_type == 1140){
        
        self.nameLabel.textColor = travleColor;
        self.conditionLabel.textColor = travleColor;
        self.ruleLabel.textColor = travleColor;
        self.timeLabel.textColor = travleColor;
        //            self.symbolLabel.textColor = travleColor;
        //            self.moneyLabel.textColor = travleColor;
        self.shopLabel.textColor = travleColor;
        [self.useButton setTitleColor:travleColor forState:UIControlStateNormal];
        self.showImageView.image = [UIImage imageNamed:@"全场_旅行"];
        self.backImageView.image = [UIImage imageNamed:@"普通旅行"];
    }
    int type = [couponModel.type intValue];
    NSString * moneyStr;
    if (type == 1) {
        
        //        self.symbolLabel.text = @"元";
        moneyStr = [NSString stringWithFormat:@"%@元",couponModel.discount];
    }else if (type == 2){
        
        //        self.symbolLabel.text = @"折";
        moneyStr = [NSString stringWithFormat:@"%@折",couponModel.discount];
    }
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:moneyStr];
    [str addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:24 * SCREENH6] range:NSMakeRange(0, moneyStr.length -1)];
    [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13 * SCREENH6] range:NSMakeRange(moneyStr.length -1, 1)];
    self.moneyLabel.attributedText = str;

    self.nameLabel.text = [NSString stringWithFormat:@"%@",couponModel.coupons_name];
    self.shopLabel.text = [NSString stringWithFormat:@"·%@",couponModel.merchants_name];
    self.conditionLabel.text = [NSString stringWithFormat:@"·满%@使用",couponModel.use_standard];
    //    NSArray * startArr = [userModel.merchants_coupons_starttime componentsSeparatedByString:@" "];
    //    NSArray * endArr = [userModel.merchants_coupons_overtime componentsSeparatedByString:@" "];
    self.timeLabel.font = [UIFont systemFontOfSize:10 * SCREENH6];
    self.timeLabel.text = [NSString stringWithFormat:@"·有效期限:%@-%@",couponModel.starttime,couponModel.overtime];
    self.ruleLabel.hidden = NO;
    self.ruleLabel.userInteractionEnabled = NO;
    self.showImageView.hidden = YES;
    self.ruleLabel.text = [NSString stringWithFormat:@"·已领取%@张",couponModel.user_get_number];
    [self.useButton setTitle:@"编辑" forState:UIControlStateNormal];
}


- (void)setUserModel:(SureUserCouponModel *)userModel{
    
    _userModel = userModel;
    
    int merchants_coupons_usable_goods_type = [userModel.merchants_coupons_usable_goods_type intValue];
    self.goodsType = [NSString stringWithFormat:@"%@",userModel.merchants_coupons_type];
    int usable_goods_type = [userModel.merchants_coupons_usable_goods_category_id intValue];
    
    if (merchants_coupons_usable_goods_type == 0) {
        
        if (usable_goods_type == 0) {
            
            self.nameLabel.textColor = allColor;
            self.conditionLabel.textColor = allColor;
            self.ruleLabel.textColor = allColor;
            self.timeLabel.textColor = allColor;
//            self.symbolLabel.textColor = allColor;
//            self.moneyLabel.textColor = allColor;
            self.shopLabel.textColor = allColor;
            [self.useButton setTitleColor:allColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_收起"];
            self.backImageView.image = [UIImage imageNamed:@"全场通用"];
        }else if (usable_goods_type == 1137){
            
            self.nameLabel.textColor = eatColor;
            self.conditionLabel.textColor = eatColor;
            self.ruleLabel.textColor = eatColor;
            self.timeLabel.textColor = eatColor;
//            self.symbolLabel.textColor = eatColor;
//            self.moneyLabel.textColor = eatColor;
            self.shopLabel.textColor = eatColor;
            [self.useButton setTitleColor:eatColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"关闭-吃喝"];
            self.backImageView.image = [UIImage imageNamed:@"全场吃喝"];
        }else if (usable_goods_type == 1138){
            
            self.nameLabel.textColor = playColor;
            self.conditionLabel.textColor = playColor;
            self.ruleLabel.textColor = playColor;
            self.timeLabel.textColor = playColor;
//            self.symbolLabel.textColor = playColor;
//            self.moneyLabel.textColor = playColor;
            self.shopLabel.textColor = playColor;
            [self.useButton setTitleColor:playColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_玩乐"];
            self.backImageView.image = [UIImage imageNamed:@"全场玩乐"];
        }else if (usable_goods_type == 1139){
            
            self.nameLabel.textColor = sportsColor;
            self.conditionLabel.textColor = sportsColor;
            self.ruleLabel.textColor = sportsColor;
            self.timeLabel.textColor = sportsColor;
//            self.symbolLabel.textColor = sportsColor;
//            self.moneyLabel.textColor = sportsColor;
            self.shopLabel.textColor = sportsColor;
            [self.useButton setTitleColor:sportsColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_运动"];
            self.backImageView.image = [UIImage imageNamed:@"全场运动"];
        }else if (usable_goods_type == 1140){
            
            self.nameLabel.textColor = travleColor;
            self.conditionLabel.textColor = travleColor;
            self.ruleLabel.textColor = travleColor;
            self.timeLabel.textColor = travleColor;
//            self.symbolLabel.textColor = travleColor;
//            self.moneyLabel.textColor = travleColor;
            self.shopLabel.textColor = travleColor;
            [self.useButton setTitleColor:travleColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_旅行"];
            self.backImageView.image = [UIImage imageNamed:@"全场旅行"];
        }
    }else if (merchants_coupons_usable_goods_type == 1){
        
        if (usable_goods_type == 0) {
            
            self.nameLabel.textColor = allColor;
            self.conditionLabel.textColor = allColor;
            self.ruleLabel.textColor = allColor;
            self.timeLabel.textColor = allColor;
//            self.symbolLabel.textColor = allColor;
//            self.moneyLabel.textColor = allColor;
            self.shopLabel.textColor = allColor;
            [self.useButton setTitleColor:allColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_收起"];
            self.backImageView.image = [UIImage imageNamed:@"全场普通"];
        }else if (usable_goods_type == 1137){
            
            self.nameLabel.textColor = eatColor;
            self.conditionLabel.textColor = eatColor;
            self.ruleLabel.textColor = eatColor;
            self.timeLabel.textColor = eatColor;
//            self.symbolLabel.textColor = eatColor;
//            self.moneyLabel.textColor = eatColor;
            self.shopLabel.textColor = eatColor;
            [self.useButton setTitleColor:eatColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"关闭-吃喝"];
            self.backImageView.image = [UIImage imageNamed:@"普通吃喝"];
        }else if (usable_goods_type == 1138){
            
            self.nameLabel.textColor = playColor;
            self.conditionLabel.textColor = playColor;
            self.ruleLabel.textColor = playColor;
            self.timeLabel.textColor = playColor;
//            self.symbolLabel.textColor = playColor;
//            self.moneyLabel.textColor = playColor;
            self.shopLabel.textColor = playColor;
            [self.useButton setTitleColor:playColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_玩乐"];
            self.backImageView.image = [UIImage imageNamed:@"普通玩乐"];
        }else if (usable_goods_type == 1139){
            
            self.nameLabel.textColor = sportsColor;
            self.conditionLabel.textColor = sportsColor;
            self.ruleLabel.textColor = sportsColor;
            self.timeLabel.textColor = sportsColor;
//            self.symbolLabel.textColor = sportsColor;
//            self.moneyLabel.textColor = sportsColor;
            self.shopLabel.textColor = sportsColor;
            [self.useButton setTitleColor:sportsColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_运动"];
            self.backImageView.image = [UIImage imageNamed:@"普通运动"];
        }else if (usable_goods_type == 1140){
            
            self.nameLabel.textColor = travleColor;
            self.conditionLabel.textColor = travleColor;
            self.ruleLabel.textColor = travleColor;
            self.timeLabel.textColor = travleColor;
//            self.symbolLabel.textColor = travleColor;
//            self.moneyLabel.textColor = travleColor;
            self.shopLabel.textColor = travleColor;
            [self.useButton setTitleColor:travleColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_旅行"];
            self.backImageView.image = [UIImage imageNamed:@"普通旅行"];
        }
    }else if (merchants_coupons_usable_goods_type == 2){
        
        if (usable_goods_type == 0) {
            
            self.nameLabel.textColor = allColor;
            self.conditionLabel.textColor = allColor;
            self.ruleLabel.textColor = allColor;
            self.timeLabel.textColor = allColor;
//            self.symbolLabel.textColor = allColor;
//            self.moneyLabel.textColor = allColor;
            self.shopLabel.textColor = allColor;
            [self.useButton setTitleColor:allColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_收起"];
            self.backImageView.image = [UIImage imageNamed:@"全场拼团"];
        }else if (usable_goods_type == 1137){
            
            self.nameLabel.textColor = eatColor;
            self.conditionLabel.textColor = eatColor;
            self.ruleLabel.textColor = eatColor;
            self.timeLabel.textColor = eatColor;
//            self.symbolLabel.textColor = eatColor;
//            self.moneyLabel.textColor = eatColor;
            self.shopLabel.textColor = eatColor;
            [self.useButton setTitleColor:eatColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"关闭-吃喝"];
            self.backImageView.image = [UIImage imageNamed:@"拼团吃喝"];
        }else if (usable_goods_type == 1138){
            
            self.nameLabel.textColor = playColor;
            self.conditionLabel.textColor = playColor;
            self.ruleLabel.textColor = playColor;
            self.timeLabel.textColor = playColor;
//            self.symbolLabel.textColor = playColor;
//            self.moneyLabel.textColor = playColor;
            self.shopLabel.textColor = playColor;
            [self.useButton setTitleColor:playColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_玩乐"];
            self.backImageView.image = [UIImage imageNamed:@"拼团玩乐"];
        }else if (usable_goods_type == 1139){
            
            self.nameLabel.textColor = sportsColor;
            self.conditionLabel.textColor = sportsColor;
            self.ruleLabel.textColor = sportsColor;
            self.timeLabel.textColor = sportsColor;
//            self.symbolLabel.textColor = sportsColor;
//            self.moneyLabel.textColor = sportsColor;
            self.shopLabel.textColor = sportsColor;
            [self.useButton setTitleColor:sportsColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_运动"];
            self.backImageView.image = [UIImage imageNamed:@"拼团运动"];
        }else if (usable_goods_type == 1140){
            
            self.nameLabel.textColor = travleColor;
            self.conditionLabel.textColor = travleColor;
            self.ruleLabel.textColor = travleColor;
            self.timeLabel.textColor = travleColor;
//            self.symbolLabel.textColor = travleColor;
//            self.moneyLabel.textColor = travleColor;
            self.shopLabel.textColor = travleColor;
            [self.useButton setTitleColor:travleColor forState:UIControlStateNormal];
            self.showImageView.image = [UIImage imageNamed:@"全场_旅行"];
            self.backImageView.image = [UIImage imageNamed:@"拼团旅行"];
        }
    }
    
    

//    self.moneyLabel.text = [NSString stringWithFormat:@"%@",userModel.merchants_coupons_discount];
    //    CGSize size = [self preferredSizeWithMaxWidth:150 * SCREENH6 withLabel:self.moneyLabel];
    int type = [userModel.merchants_coupons_type intValue];
    NSString * moneyStr;
    if (type == 1) {

//        self.symbolLabel.text = @"元";
        moneyStr = [NSString stringWithFormat:@"%@元",userModel.merchants_coupons_discount];
    }else if (type == 2){

//        self.symbolLabel.text = @"折";
        moneyStr = [NSString stringWithFormat:@"%@折",userModel.merchants_coupons_discount];
    }

    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:moneyStr];
    [str addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:24 * SCREENH6] range:NSMakeRange(0, moneyStr.length -1)];
    [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13 * SCREENH6] range:NSMakeRange(moneyStr.length -1, 1)];
    self.moneyLabel.attributedText = str;

    self.nameLabel.text = [NSString stringWithFormat:@"%@",userModel.coupons_name];
    self.shopLabel.text = [NSString stringWithFormat:@"·%@",userModel.merchants_name];
    self.conditionLabel.text = [NSString stringWithFormat:@"·满%@使用",userModel.merchants_coupons_use_standard];
    [self.useButton setTitle:@"立即使用" forState:UIControlStateNormal];
//    NSArray * startArr = [userModel.merchants_coupons_starttime componentsSeparatedByString:@" "];
//    NSArray * endArr = [userModel.merchants_coupons_overtime componentsSeparatedByString:@" "];
    self.timeLabel.text = [NSString stringWithFormat:@"·作废时间:%@",userModel.out_time];
    
    CGFloat height = self.backImageView.bottom;
    if (userModel.explain) {
        
        self.ruleLabel.hidden = NO;
        self.showImageView.hidden = NO;
        self.ruleContentLabel.text = userModel.explain;
        
//        self.showImageView.transform = CGAffineTransformIdentity;

        if ([self.type isEqualToString:@"show"]) {

            [UIView animateWithDuration:0.25 animations:^{
                self.showImageView.transform = CGAffineTransformIdentity;
            }];

            CGSize attrStrSize = [self preferredSizeWithMaxWidth:315 * SCREENH6 withLabel:self.ruleContentLabel];
            CGFloat labH = attrStrSize.height;

            self.ruleContentLabel.frame = CGRectMake(30 * SCREENH6, self.backImageView.bottom, 315 * SCREENH6, labH);

            height = self.ruleContentLabel.bottom + 5 * SCREENH6;
        }else{

            [UIView animateWithDuration:0.25 animations:^{
                CGAffineTransform transform= CGAffineTransformMakeRotation(M_PI);
                self.showImageView.transform = transform;
            }];

            self.ruleContentLabel.frame = CGRectZero;
        }
        
    }else{
        
        CGAffineTransform transform= CGAffineTransformMakeRotation(M_PI);
        self.showImageView.transform = transform;
        
        self.ruleLabel.hidden = YES;
        self.showImageView.hidden = YES;
    }

    _userModel.rowHeight =  height + 5 * SCREENH6;
}

- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = ZRWhiteColor;
    
    UIImageView * backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(37 * SCREENH6, 0, 300 * SCREENH6, 105 * SCREENH6)];

    backImageView.image = [UIImage imageNamed:@"新通用"];
    backImageView.userInteractionEnabled = YES;
    self.backImageView = backImageView;

    [self.contentView addSubview:self.backImageView];

    self.nameLabel = [self setupLabelWithTitle:@"优惠券名字"];
    self.nameLabel.font = [UIFont boldSystemFontOfSize:14 * SCREENH6];
    [self.backImageView addSubview:self.nameLabel];
    self.shopLabel = [self setupLabelWithTitle:@"·店名"];
    [self.backImageView addSubview:self.shopLabel];
    self.conditionLabel = [self setupLabelWithTitle:@"·满50使用"];
    [self.backImageView addSubview:self.conditionLabel];
    self.timeLabel = [self setupLabelWithTitle:@"截止时间:2018.01.16-2018.01.05"];
//    self.timeLabel.font = [UIFont systemFontOfSize:8 * SCREENH6];
    [self.backImageView addSubview:self.timeLabel];
    self.ruleLabel = [self setupLabelWithTitle:@"使用规则"];
    self.ruleLabel.userInteractionEnabled = YES;
    //创建轻拍手势
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    [self.ruleLabel addGestureRecognizer:tapGR];
    [self.backImageView addSubview:self.ruleLabel];
//    self.symbolLabel = [self setupLabelWithTitle:@"￥"];
//    self.symbolLabel.textColor = ZRWhiteColor;
//    self.symbolLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
//    self.symbolLabel.textAlignment = NSTextAlignmentRight;
//    [self.backImageView addSubview:self.symbolLabel];
    self.moneyLabel = [self setupLabelWithTitle:@"5"];
    self.moneyLabel.textColor = ZRWhiteColor;
    self.moneyLabel.textAlignment = NSTextAlignmentCenter;
//    self.moneyLabel.font = [UIFont boldSystemFontOfSize:24 * SCREENH6];
    [self.backImageView addSubview:self.moneyLabel];
    
    UIImageView * showImageView = [UIImageView new];
    
    showImageView.image = [UIImage imageNamed:@"关闭 -通用"];
    CGAffineTransform transform= CGAffineTransformMakeRotation(M_PI);
    showImageView.transform = transform;
    
    self.showImageView = showImageView;
    
    [self.backImageView addSubview:self.showImageView];
    
    UIButton * useButton = [UIButton new];
    
//    [useButton setTitle:@"立即使用" forState:UIControlStateNormal];
//    [useButton setTitleColor:ZRWhiteColor forState:UIControlStateNormal];
    useButton.backgroundColor = ZRWhiteColor;
    useButton.titleLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    [useButton addTarget:self action:@selector(clickUseButton) forControlEvents:UIControlEventTouchUpInside];
    
    self.useButton = useButton;
    
    [self.backImageView addSubview:self.useButton];
    
    
    UILabel * contentLabel = [UILabel new];
    
    contentLabel.textColor = [UIColor lightGrayColor];
    contentLabel.font = [UIFont systemFontOfSize:12 * SCREENH6];
    contentLabel.numberOfLines = 0;
    
    self.ruleContentLabel = contentLabel;
    
    [self.contentView addSubview:self.ruleContentLabel];
    
}


- (void)layoutSubviews{
    
//    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.contentView);
//        make.height.mas_equalTo(95 * SCREENH6);
//        make.leading.mas_equalTo(self.contentView).offset(30 * SCREENH6);
//        make.width.mas_equalTo(315 * SCREENH6);
//    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.backImageView).offset(25 * SCREENH6);
        make.trailing.mas_equalTo(self.contentView).offset(-120 * SCREENH6);
        make.top.mas_equalTo(self.backImageView).offset(12 * SCREENH6);
    }];
    
    [self.shopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.nameLabel);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(7 * SCREENH6);
    }];
    
    [self.conditionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.shopLabel);
        make.top.mas_equalTo(self.shopLabel.mas_bottom).offset(3 * SCREENH6);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.conditionLabel);
        make.top.mas_equalTo(self.conditionLabel.mas_bottom).offset(3 * SCREENH6);
    }];
    
    [self.useButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(60 * SCREENH6);
        make.height.mas_equalTo(20 * SCREENH6);
        make.trailing.mas_equalTo(self.backImageView).offset(-17 * SCREENH6);
        make.bottom.mas_equalTo(self.backImageView).offset(-25 * SCREENH6);
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.useButton);
        make.bottom.mas_equalTo(self.useButton.mas_top).offset(-12 * SCREENH6);
    }];
    
//    [self.symbolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.mas_equalTo(self.useButton.centerX);
//        make.bottom.mas_equalTo(self.moneyLabel);
//    }];

    [self.ruleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.timeLabel);
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(3 * SCREENH6);
    }];
    
    
    
    [self.showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.ruleLabel.mas_trailing);
        make.centerY.mas_equalTo(self.ruleLabel).offset(1 * SCREENH6);
//        make.width.height.mas_equalTo(15 * SCREENH6);
        make.width.mas_equalTo(9 * SCREENH6);
        make.height.mas_equalTo(5 * SCREENH6);
    }];

}


- (UILabel *)setupLabelWithTitle:(NSString *)title{
    
    UILabel * label = [UILabel new];
    
    label.textColor = allColor;
    label.font = [UIFont systemFontOfSize:11 * SCREENH6];
    label.text = title;
    
    return label;
}

- (CGSize)preferredSizeWithMaxWidth:(CGFloat)maxWidth withLabel:(UILabel *)label
{
    
    CGSize size = [label sizeThatFits:CGSizeMake(maxWidth, 10000000.0f)];
    size.width = fmin(size.width, maxWidth); //在numberOfLine为1模式下返回的可能会比maxWidth大，所以这里我们限制下
    return size;
}


- (void)tapAction{

    if (!self.type) {
        
        self.type = @"show";

    }else{
        
        if ([self.type isEqualToString:@"hidden"]) {
            
            self.type = @"show";
        }else{
            
            self.type = @"hidden";
        }
    }

    if (self.delegate && [self.delegate respondsToSelector:@selector(clickUnfoldButton)])
    {
        
        [self.delegate clickUnfoldButton];
    }
    
}


- (void)clickUseButton{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickUseButtonWithCell:)])
    {
        [self.delegate clickUseButtonWithCell:self];
    }
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
